-- Wabtec Railway Electronics - Proprietary and Confidential Information
// This script simply connects to the Debug Client and dumps its logs every X seconds

start
int DebugCounter = 0
int LogDumpCounter = 0
int LogDumpInterval = 3 * 60 // in seconds
int LoopWaitTime = 500 // in milliseconds
int LogDumpCounterTrip = LogDumpInterval * 1000 / LoopWaitTime

connect SLICE1
wait 5000

@Loop1 
    set DebugCounter += 1
    set LogDumpCounter += 1
    
    // Every LogDumpInterval seconds, dump logs
    if (LogDumpCounter == LogDumpCounterTrip) gosub DumpIntermediateLog
    if (LogDumpCounter == LogDumpCounterTrip) set LogDumpCounter = 0
    
    wait LoopWaitTime
if (1) gosub Loop1
end 

///////////////////// CLERICAL SUBROUTINES

@DumpIntermediateLog
    print("LOG DUMP INTERVAL OF %s SECONDS REACHED. Dumping intermediate log.", LogDumpInterval)
    
	save_output "output\InfLoop_Decreasing_Intermediate"
	reset_output
	
    SLICE1::DBG_LOG_SAVE_CURRENT_WTS("output\InfLoop_Decreasing_Intermediate.rtf")
	SLICE1::DBG_LOG_CLEAR_CURRENT
return

///////////////////// END LOOPING SUBROUTINES